﻿Imports System
Imports System.Runtime.Serialization

''' <summary>
''' Exception raised if an attempt is made to add aprojection to an aggregate that already has a
''' projection of that name
''' </summary>
<Serializable()>
Public NotInheritable Class ProjectionNameExistsException
    Inherits Exception

    Private ReadOnly m_duplicateName As String
    Public ReadOnly Property DuplicateName As String
        Get
            Return m_duplicateName
        End Get
    End Property

#Region "Serialisation"

    Public Overrides Sub GetObjectData(info As SerializationInfo, context As StreamingContext)
        MyBase.GetObjectData(info, context)
        If (info IsNot Nothing) Then
            info.AddValue(NameOf(DuplicateName), m_duplicateName)
        End If
    End Sub

#End Region

    Public Sub New(ByVal duplicateNameIn As String)
        MyBase.New("Duplicate projection name : " & duplicateNameIn)
        m_duplicateName = duplicateNameIn
    End Sub

    Public Sub New(ByVal duplicateNameIn As String, ByVal innerException As Exception)
        MyBase.New("Duplicate projection name : " & duplicateNameIn, innerException)
        m_duplicateName = duplicateNameIn
    End Sub

    Public Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
        MyBase.New(info, context)
        If (info IsNot Nothing) Then
            m_duplicateName = info.GetString(NameOf(DuplicateName))
        End If
    End Sub
End Class
